package com.hmyuan.webdesktop.service;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.hmyuan.webdesktop.domain.UserIcon;
import com.hmyuan.webdesktop.mapper.UserIconMapper;

@Service
public class UserIconService {

	@Resource
	UserIconMapper userIconMapper;
	/**
	 * 查询用户可以显示的图标根据用户id
	 * @param userId
	 * @return
	 */
	public List<UserIcon> findUserIconToShowByUserId(int userId){
		UserIcon ui = new UserIcon();
		ui.setUserId(userId);
		return userIconMapper.findList(ui);
	}
	/**
	 * 查询桌面图标
	 */
	public List<UserIcon> findList(UserIcon ui){
		return userIconMapper.findList(ui);
	}
	/**
	 * 更新一条数据
	 * @param userIcon
	 */
	public boolean update(UserIcon userIcon) {
		// TODO Auto-generated method stub
		int num = userIconMapper.updateByPrimaryKeyWithBLOBs(userIcon);
		return num==1?true:false;
	}
	/**
	 * 新增一条数据
	 * @param userIcon
	 */
	public boolean save(UserIcon userIcon) {
		// TODO Auto-generated method stub
		userIcon.setCreatetime(new Date());
		int num = userIconMapper.insert(userIcon);
		return num==1?true:false;
	}
	/**
	 * 根据id删除一条数据
	 * @param id
	 * @return 
	 */
	public boolean deleteById(Integer id) {
		// TODO Auto-generated method stub
		int num = userIconMapper.deleteByPrimaryKey(id);
		return num==1?true:false;
	}
}
